package cn.bincker.mybatis.encrypt.core;

import cn.bincker.mybatis.encrypt.converter.EncryptConvertRegister;
import cn.bincker.mybatis.encrypt.entity.EncryptProperty;
import cn.bincker.mybatis.encrypt.entity.IntegrityCheckProperty;
import cn.bincker.mybatis.encrypt.entity.SecurityProperty;

import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;

public interface EncryptExecutor {
    Encryptor getEncryptor();
    EncryptKeyProvider getKeyProvider();
    EncryptConvertRegister getConverterRegister();
    boolean isEncryptField(Class<?> clazz, String fieldName);
    void setExecutorService(ExecutorService executorService);
    Optional<SecurityProperty> getSecurityProperty(Class<?> clazz, String fieldName);

    boolean hasEncryptField(Class<?> clazz);

    Map<String, SecurityProperty> getEncryptFields(Class<?> clazz);

    byte[] encrypt(EncryptProperty property, Object target, Object value);

    Future<?> putEncryptTask(EncryptProperty property, Object target, Object data);

    Object decrypt(EncryptProperty property, Object target, byte[] data);

    Future<?> putDecryptTask(EncryptProperty property, Object target, byte[] data);

    byte[] messageDigest(IntegrityCheckProperty property, Object target);

    byte[] checkIntegrity(IntegrityCheckProperty property, Object target, byte[] value);

    Future<?> putIntegrityCheckTask(IntegrityCheckProperty property, Object target, byte[] value);
}
